package org.jyrcp.base;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory
{

	public void createInitialLayout(IPageLayout layout)
	{
		String packageName = TextUtils.shortenPackageName(layout.getDescriptor().getId());
		String className = TextUtils.packageNameToClassName(packageName);

		JyRCPApplication.interpreter.exec("from perspectives." + packageName + " import " + className);
		JyRCPApplication.interpreter.exec("perspective = " + className + "()");
		PerspectiveCreator pythonPerspectiveCreator = (PerspectiveCreator)
			JyRCPApplication.interpreter.get("perspective", PerspectiveCreator.class);
		
		pythonPerspectiveCreator.createInitialLayout(layout);
	}

}
